<?PHP	//header
include('config/config.php');
require "php/functions.php";
?>
<?PHP
	$conn = mysql_connect($cfg["connection"]["host"], $cfg["connection"]["userName"], $cfg["connection"]["password"]) 
		or die ('Error Cannot Connect to MySQL');
	@mysql_select_db($cfg["connection"]["database"]) or die( "Unable to select database");
	
	if (isset($_POST['username'], $_POST['password'])) {
		$username = db_escape_string($_POST['username']);
		$password = db_escape_string($_POST['password']);
		$query = "SELECT COUNT(*) FROM adm WHERE name = '".$username."' AND password = MD5('".$password."');";
		$result = mysql_query($query);
		$row = mysql_fetch_array($result) or die(mysql_error());
	
		if($row[0] == 1){
			//Validation Successful
			header("Location: ./delete_inventory.php");
		} else {
			//unselect selected items (for delete)
			session_start();
			$_SESSION['checkbox_Inventory'] = array();
			unset($_SESSION['checkbox_Inventory']);
			header("Location: ./delete_inventory.php");
		}
	}
?>